package com.gofun.framework.core.property;

import java.beans.PropertyEditorSupport;
import java.math.BigDecimal;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gofun.framework.core.utils.StringUtils;


public class CustomBigDecimalEditor extends PropertyEditorSupport {
	
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		try {
			if(!StringUtils.hasText(text)){
				setValue(null);
				return;
			}
			BigDecimal big = new BigDecimal(text);
			setValue(big);
			return;
		} catch (Exception e1) {
			logger.error("解析java.util.BigDecimal类型属性时发生异常,未知的数据格式,BigDecimal:" + text,e1);
		}
	}
}
